package api

import (
	"api/serializer"
	"api/service"
	"api/util"

	"github.com/gin-gonic/gin"
)

// API 测试写法
func API(c *gin.Context) {
	//日志打印

	logger := util.Log()

	logger.Debug("test logger")
	//调用service
	var computer service.Comsss

	if err := c.ShouldBind(&computer); err != nil {
		logger.Error("Bind Error:", err)
		c.JSON(500, ErrorResponse(err))
	} else {
		res := computer.DoComputer()

		logger.Info("Pings: ", res)

		c.JSON(200, serializer.Response{
			Code: 200,
			Data: res,
			Msg:  "success msg",
		})
	}

}
